#pragma once

#include "TGListenThread.h"
#include "TGSvrNetCfg.h"

//#include "SvrNetLoginMan.h"
#include "SvrNetRealStreamMan.h"
// #include "SvrNetTalkItem.h"
// 
// #include "SvrNetFileMan.h"



class TGSvrNetMan :public TGListenThread, public TGSvrNetCfg
{
public:
	TGSvrNetMan(void);
	~TGSvrNetMan(void);

public: // this is client
	SvrNetRPCamera *m_pNetRPCamera ;

	TGERR_CODE Login(TG_CONNECT_INFO *pChatInfo);
	TGERR_CODE Logoff();

	int		TcpRecvLoginInfo(IN SOCKET hSocket,IN  DWORD dwTimeOut,IN WSAEVENT hExitEvent,OUT NET_PACKET_HEAD *pNetMstHead);
	int		TcpRecvLoginInfo(SOCKET hSocket,DWORD dwTimeOut,OUT NET_PACKET_HEAD* pNetMstHead);
public:
	int SvrStart();
	int SvrStop();

public:

private:
	virtual int vTcpCmdDispatch(SOCKET hClientSocket,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);

private:
	virtual int vUdpCmdDispatch(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	int UdpCmdCommand(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	

private:
	virtual int vTcpDataDispatch(SOCKET hClientSocket,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);

private:
	virtual int vUdpDataDispatch(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);
	int UdpDataCommand(SOCKET hSocket,TG_UDP_ADDR *pAddr,NET_PACKET_HEAD *pMsgHead,BYTE *pBuffer);

public:
	SvrNetRealStreamMan m_xRealStreamMan;


public:
#ifdef dkq_test_svrnet
	TGLogInfo m_xLog;
#endif
	
};

//extern TGSvrNetMan g_TGSvrNetMan;